package com.ljf.authority.web;

import com.ljf.authority.dto.command.*;
import com.ljf.authority.dto.query.AuthorityBaseMenuTabulationQuery;
import com.ljf.authority.service.IAuthorityBaseMenuTabulationService;
import com.ljf.authority.vo.AuthorityBaseMenuTabulationVO;
import com.ljf.common.exception.ServiceException;
import com.ljf.common.result.ResultModel;
import com.ljf.common.validation.UpdateGroup;
import com.ljf.common.web.BasisController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 菜单列表定义  控制器
 *
 * @author LJF
 * @since 2024-10-17
 */
@RestController
@RequestMapping("/authority/base/menu_tabulation")
@Api(value = "菜单列表定义接口", tags = "菜单列表定义接口")
public class AuthorityBaseMenuTabulationController extends BasisController<IAuthorityBaseMenuTabulationService, AuthorityBaseMenuTabulationQuery, AuthorityBaseMenuTabulationVO, AuthorityBaseMenuTabulationCommand> {

    @PutMapping("/sort")
    @ApiOperation(value = "修改菜单列表排序接口")
    public ResultModel editSort(@RequestBody @Validated(UpdateGroup.class) AuthorityBaseMenuTabulationSortCommand command) throws ServiceException {
        return service.editSort(command);
    }

    @PutMapping("/detail")
    @ApiOperation(value = "修改菜单列表明细接口")
    public ResultModel editDetail(@RequestBody @Validated(UpdateGroup.class) AuthorityBaseMenuTabulationDetailCommand command) throws ServiceException {
        return service.editDetail(command);
    }

    @PutMapping("/backend")
    @ApiOperation(value = "修改菜单列表关联后端接口")
    public ResultModel editBackend(@RequestBody @Validated(UpdateGroup.class) AuthorityBaseMenuTabulationBackendCommand command) throws ServiceException {
        return service.editBackend(command);
    }

    @PutMapping("/method")
    @ApiOperation(value = "修改菜单列表按钮方法接口")
    public ResultModel editMethod(@RequestBody @Validated(UpdateGroup.class) AuthorityBaseMenuTabulationMethodCommand command) throws ServiceException {
        return service.editMethod(command);
    }

    @PutMapping("/activation")
    @ApiOperation(value = "修改菜单列表激活状态接口")
    public ResultModel editActivation(@RequestBody @Validated(UpdateGroup.class) AuthorityBaseMenuTabulationActivationCommand command) throws ServiceException {
        return service.editActivation(command);
    }

    @PutMapping("/permission_group")
    @ApiOperation(value = "修改菜单列表关联权限组接口")
    public ResultModel editPermissionGroup(@RequestBody @Validated(UpdateGroup.class) AuthorityBaseMenuTabulationPermissionGroupCommand command) throws ServiceException {
        return service.editPermissionGroup(command);
    }

    @GetMapping("/sort/{id}")
    @ApiOperation(value = "根据ID查询菜单树排序接口")
    public ResultModel querySortById(@PathVariable Long id) throws ServiceException {
        return service.querySortById(id);
    }

    @GetMapping("/menu_tree")
    @ApiOperation(value = "菜单树")
    public ResultModel queryMenuTree() throws ServiceException {
        return service.queryMenuTree();
    }

    @GetMapping("/detail/{id}")
    @ApiOperation(value = "根据ID查询菜单树明细接口")
    public ResultModel queryDetailById(@PathVariable Long id) throws ServiceException {
        return service.queryDetailById(id);
    }

    @GetMapping("/backend/{id}")
    @ApiOperation(value = "根据ID查询菜单关联后端接口")
    public ResultModel queryBackendById(@PathVariable Long id) throws ServiceException {
        return service.queryBackendById(id);
    }

    @GetMapping("/method/{id}")
    @ApiOperation(value = "根据ID查询菜单按钮方法接口")
    public ResultModel queryMethodById(@PathVariable Long id) throws ServiceException {
        return service.queryMethodById(id);
    }

    @GetMapping("/permission_group/{id}")
    @ApiOperation(value = "根据ID查询菜单权限组接口")
    public ResultModel queryPermissionGroupById(@PathVariable Long id) throws ServiceException {
        return service.queryPermissionGroupById(id);
    }

    @GetMapping("/tree")
    @ApiOperation(value = "权限树")
    public ResultModel tree() throws ServiceException {
        return service.tree();
    }

    @GetMapping("/button")
    @ApiOperation(value = "权限按钮")
    public ResultModel button(String componentUrl) throws ServiceException {
        return service.button(componentUrl);
    }

}